package cn.iocoder.yudao.module.xkfz.controller.admin.basic;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.xkfz.domain.entity.basic.DeptBasic;
import cn.iocoder.yudao.module.xkfz.domain.entity.basic.IndicatorTree;
import cn.iocoder.yudao.module.xkfz.domain.po.basic.IndicatorTreePo;
import cn.iocoder.yudao.module.xkfz.mapper.basic.DeptBasicMapper;
import cn.iocoder.yudao.module.xkfz.service.basic.IndicatorTreeService;
import cn.iocoder.yudao.module.xkfz.service.operationalPerformance.MetricDirectScoreService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@RestController
@RequestMapping("/indicatorTree")
@Validated
@Slf4j
public class IndicatorTreeController {
    @Autowired
    IndicatorTreeService indicatorTreeService;
    @Autowired
    DeptBasicMapper deptBasicMapper;
    @GetMapping("/queryIndicatorList")
    @Operation(summary = "指标查询接口")
    public CommonResult<List<IndicatorTree>> indicatorList(IndicatorTreePo indicatorTreePo) {
        List<IndicatorTree> indicatorTreeList = indicatorTreeService.
                queryIndicatorTree( indicatorTreePo );
        return success(indicatorTreeList);
    }

    @PostMapping("/insertIndicatorTree")
    @Operation(summary = "新增基础指标")
    public CommonResult<Boolean> insertIndicatorTree(@RequestBody IndicatorTreePo indicatorTreePo) {
        return success(indicatorTreeService.insertIndicatorTree(indicatorTreePo));
    }
    @PostMapping("/updateIndicatorTree")
    @Operation(summary = "修改基础指标")
    public CommonResult<Boolean> updateIndicatorTree(@RequestBody IndicatorTreePo indicatorTreePo) {
        return success(indicatorTreeService.updateIndicatorTree(indicatorTreePo));
    }


    @GetMapping("/deleteIndicatorTree")
    @Operation(summary = "删除基础指标")
    public CommonResult<Boolean> deleteIndicatorTree(String id) {
        return success(indicatorTreeService.deleteIndicatorTree(id));
    }
    @GetMapping("/queryCurrentParticipatingDepartments")
    @Operation(summary = "查询当前参评科室")
    public CommonResult<List<DeptBasic>> queryCurrentParticipatingDepartments(String year) {
        List<DeptBasic> deptBasicList = deptBasicMapper.selectList("year", year);
        return success(deptBasicList);
    }
    @PostMapping("/addCurrentParticipatingDepartments")
    @Operation(summary = "新增参评科室")
    public CommonResult<Boolean> addCurrentParticipatingDepartments(List<DeptBasic> deptBasicList) {
        return success(deptBasicMapper.insertBatch(deptBasicList));
    }
    @PostMapping("/updateCurrentParticipatingDepartments")
    @Operation(summary = "修改参评科室")
    public CommonResult<Boolean> updateCurrentParticipatingDepartments(List<DeptBasic> deptBasicList) {
        return success(deptBasicMapper.updateBatch(deptBasicList));
    }

}
